package com.ecoolex.ying.space.ws;

import java.util.Date;

import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import com.ecoolex.framework.common.exception.BizException;
import com.ecoolex.framework.common.pojo.Page;
import com.ecoolex.framework.common.pojo.Pagination;
import com.ecoolex.framework.common.pojo.Sorting;
import com.ecoolex.ying.space.core.manager.UserLikeAndFavoriteReadStateManager;
import com.ecoolex.ying.space.core.manager.UserLikeRecordManager;
import com.ecoolex.ying.space.entity.UserLikeRecord;
import com.ecoolex.ying.space.pojo.UserLikeAndFavoriteDTO;

@Service
public class UserLikeRecordServiceImpl implements UserLikeRecordService{
	
	@Autowired
	private UserLikeRecordManager userLikeRecordManager;

	@Override
	public boolean add(UserLikeRecord record,Integer userId, String createUser) throws BizException {
		return userLikeRecordManager.add(record,userId, createUser);
	}

	@Override
	public boolean delete(UserLikeRecord record, String updateUser) throws BizException {
		return userLikeRecordManager.delete(record, updateUser);
	}

	@Override
	public Pagination<UserLikeRecord> queryByUserId(Integer userId,Sorting[] sorts,Page page) {
		return userLikeRecordManager.queryByUserId(userId, sorts, page);
	}

	@Override
	public Pagination<UserLikeAndFavoriteDTO> queryByContentAuthorUserId(Integer contentAuthorUserId,Date now,Sorting[] sorts,Page page) {
		return userLikeRecordManager.queryByContentAuthorUserId(contentAuthorUserId,now,sorts,  page);
	}

	@Override
	public UserLikeRecord getByUserIdAndTypeAndContentId(Integer userId, Integer type, Integer contentId) {
		return userLikeRecordManager.getByUserIdAndTypeAndContentId(userId, type, contentId);
	}

	@Override
	public Integer userLikeCountByContentAuthorUserId(Integer userId) {
		return userLikeRecordManager.userLikeCountByContentAuthorUserId(userId);
	}
	
	@Autowired
	private UserLikeAndFavoriteReadStateManager userLikeAndFavoriteReadStateManager;

	@Override
	public void updateReceivedUserLikeAndFavoriteReadState(Integer readUserId, String createUser) {
		userLikeAndFavoriteReadStateManager.updateReceivedUserLikeAndFavoriteReadState(readUserId, createUser);
	}

	@Override
	public long unreadReceivedUserLikeAndFavoriteCount(Integer userId) {
		return userLikeRecordManager.unreadReceivedUserLikeAndFavoriteCount(userId);
	}

}
